<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script type="text/javascript">
			
			/*var mrDeng = {
				name : "mrDeng",
				age : 40,
				sex : "male",
				health : 100,
				smoke : function(){
					console.log(('I am smoking!'));
					this.health --;
				},
				
				drink : function(){
					console.log('I am drink');
					this.health ++;
				}
			}*/
			
			/*//对象没有的属性出现undefined
			var mrDeng = {
				name : "mrDeng",
				age : 40,
				sex : "male",
				health : 100,
				smoke : function(){
					console.log(('I am smoking!'));
					this.health --;
				},
				
				drink : function(){
					console.log('I am drink');
					this.health ++;
				}
			}
			
			mrDeng.wife = "小刘";//属性增加
			console.log(mrDeng.sex);//属性查看
			mrDeng.sex = "female";//改
			delete mrDeng.name;//删除属性*/
			
			/*var deng = {
				prepareWife : "xiaowang",
				name : "laodeng",
				sex : "male",
				gf : "xiaoliu",
				wife : "",
				divorce : function(){
					delete this.wife;
					this.gf = this.prepareWife;
				},
				
				getMarried : function(){
					this.wife = this.gf;
				},
				
				changePrepareWife : function(someone){
					this.gf = someone;
				}
			}*/
			
			//对象的创建方法
			//1. var obj = {}  plainObject 对象字面量/对象直接量
			//2.构造函数
			//  1) 系统自带的构造函数   Object() var obj = new Object()
			//	2) 自定义//符合大驼峰命名规则
			/*var obj = new Object();
			obj.name = 'abc';
			obj.sex = 'female';*/
			
/*			function Person(){
				
			}
			var person = new Person();//生成对象*/
			
			/*function Car(){
				this.name = "BMW";
				this.height = "1400";
				this.lang = "4900";
				this.weight = 1000;
				this.health = 100;
				this.run = function(){
					this.health--;
				}
				
			}
			var car = new Car();
			var car1 =new Car();
			car.name = "Maserati";
			car1.name = "Merz";*/
			
			/*function Student(name,age,sex){
				this.name = 
				this.age = age;
				this.sex = sex;
				this.grade = 2017;
			}
			
			var student1 = new Student('zhangsan',18,'male');*/
			
			//构造函数内部原理
			//1.在函数体最前面隐式的加上this = {}
			//2.执行this.xxx = xxx;
			//3.隐式的返回this
			
			/*function Person(name,height){
				this.name = name;
				this.height = height;
				this.say = function(){
					console.log(this.say);
				}
			}
			console.log(new Person('xiaowang',18).name);*/
			
			/*function Person(name,height){
				var that = {};
				that.name = name;
				that.height = height;
				return that;
			}
			console.log(new Person('xiaowang',18).name);*/
			
			/*function Person(name,height){
				this.name = name;
				this.height = height;
				this.say = function(){
					console.log(this.say);
				}
				return {};
			}
			console.log(new Person('xiaowang',18).name);//undefined*/
			
			/*function Person(name,height){
				this.name = name;
				this.height = height;
				this.say = function(){
					console.log(this.say);
				}
				return 123;
			}
			console.log(new Person('xiaowang',18).name);//正常*/
			
			/*var num = new Number(123);
			num.a = "a";
			console.log(num.a);//a
			console.log(num * 2);//246*/
			
			/*//包装类
			var str = "abcd";
			str.abc = 'a';
			var num = 4;
			//new Number(4).len = 3; delete
			num.len = 4;
			//new Number(4).len//没有
			console.log(num.len);//undefiend*/
			
			/*var str = "abcd";
			str.length = 2;
			console.log(str);//abcd*/
			
			/*var str = "abc";
			str += 1;
			var test = typeof(str);
			if(test.length == 6){
				test.sign = "typeof返回值可能为String";
			}
			console.log(test.sign);//undefined*/
			
			/*function Person(name,age,sex){
				var a = 0;
				this.name = name;
				this.age = age;
				this.sex =sex;
				function sss(){
					a ++;
					document.write(a);
				}
				this.say = sss;
			}
			
			var oPerson = new Person();
			oPerson.say();//1
			oPerson.say();//2
			var oPerson1 = new Person();
			oPerson1.say();//1*/
			
			/*var x = 1,y = z = 0;
			function add(n){
				return n = n+1;
			}
			y = add(x);
			function add(n){
				return n = n + 3;
			}
			z = add(x);
			console.log(x + " " + y + " " + z)//1 4 4*/
			
			
			
			
			
			
		</script>
	</body>
</html>
